package com.volcreate.week2_3.no1;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * 属性：name(String)、gender（boolean)、age(int)、id(int) ，所有的变量必须为私有(private)。
 * 无参构造函数:Person(), 功能：打印This is constructor 。
 * 有参构造函数:Person(name, gender, age) ，功能：给属性赋值。
 * 建议：使用Eclipse自动生成toString方法
 *
 * @author zxc
 * @date 2020/9/21
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        scanner.nextLine();
        List<List<String>> lists = new ArrayList<>();
        ArrayList<Person> people = new ArrayList<>();
        for (int i1 = 0; i1 < i; i1++) {
            String s = scanner.nextLine();
            String[] split = s.split("\\s");
            List<String> list = new ArrayList<>(Arrays.asList(split));
            lists.add(list);
        }
        for (int i1 = 0; i1 < i; i1++) {
            List<String> list = lists.get(i1);
            Person person = new Person(list.get(0), Integer.parseInt(list.get(1)), Boolean.parseBoolean(list.get(2)));
            people.add(person);
        }
        for (int i1 = people.size() - 1; i1 >= 0; i1--) {
            System.out.println(people.get(i1));
        }
        Person person = new Person();
        System.out.println(person);
        scanner.close();
    }
}

class Person {
    private String name;
    private boolean gender;
    private int age;
    private int id;
    private static int num;

    static {
        System.out.println("This is static initialization block");
    }

    {
        id = num;
        System.out.println("This is initialization block, id is " + id);
        num++;
    }

    public Person() {
        System.out.println("This is constructor");
        System.out.println(name+","+age+","+gender+","+id);
    }

    public Person(String name, int age, boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }


    @Override
    public String toString() {
        return "Person [" +
                "name=" + name +
                ", age=" + age +
                ", gender=" + gender +
                ", id=" + id +
                ']';
    }


}
